import os
import shutil
import sys

def comp_del(com_filename,orgpath,aimPath):   
    n = 0
    for fpath,fdir,ffile in os.walk(aimPath):
        while n < len(ffile):
            print(fpath+"/"+ffile[n])
            if com_filename == ffile[n]:
                os.remove(fpath+"/"+ffile[n])
                (aimPath + '\\' + ffile[n])
                print('update_file--------' + orgpath + '\\' + ffile[n] + '\n')
            n = n + 1
     
def mov_file(ndfile,edfile,fpos):
    shutil.move(ndfile + '\\' + fpos,edfile)
 
def mov_file_all(filePath,aimPath):
    for i,j,k in os.walk(filePath):
        filedir = eval(repr(i).replace('\\', '\\\\'))
        pos = 0
        while pos < len(k):
            comp_del(k[pos],filedir,aimPath)
            mov_file(filedir,aimPath,k[pos])
            pos = pos + 1
 
if len(sys.argv) > 2:
    filedir = sys.argv[1]
    aimPath = sys.argv[2]
    mov_file_all(filedir,aimPath)
    sys.exit
else:
    print("Parameter Error")
    print("Parameter Is : zip.py [zipfile] [directory]")
    sys.exit

